package rs.frenjoynet.core.core.util;

import java.net.URL;
import java.io.InputStream;
import java.io.File;
import java.io.IOException;
import java.util.Properties;

/**
 * Created by IntelliJ IDEA.
 * User: ppopovic
 * Date: 29.10.2009.
 * Time: 15.09.22
 * To change this template use File | Settings | File Templates.
 */
public class ResourceProperties
{
	private Properties properties;
	private String file;

	public ResourceProperties(String file)
	{
		if (!file.contains(".properties"))
			throw new RuntimeException("File not exists, or havnot demand format .properties..");
		this.file = file;
		URL webResource = Thread.currentThread().getContextClassLoader().getResource(file);
		if (webResource == null)
			throw new RuntimeException("Resource : " + file + " doesnot exists..");
		//System.out.println(webResource.getFile());
		try
		{
			properties = new Properties();
			properties.load(webResource.openStream());
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

	}

	public String getKey(String key)
	{
		return (String)properties.get(key);
	}


}
